﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace System.Data.SQLiteProvider
{
    public static class SQLiteDbService
    {
        public static bool ExistDb(string dbPath)
        {
            var res = false;
            res = System.IO.File.Exists(dbPath);
            return res;
        }

        public static bool CreateDb(string dbPath)
        {
            var res = false;
            try
            {
                System.Data.SQLite.SQLiteConnection.CreateFile(dbPath);
                res = true;
            }
            catch (Exception ex)
            {
                throw new Exception(ex.InnerException != null ? ex.InnerException.Message : ex.Message);
            }
            return res;
        }

        public static bool DeleteDbFile(string dbPath)
        {
            var res = false;
            try
            {
                System.IO.File.Delete(dbPath);
                res = true;
            }
            catch (Exception ex)
            {
                throw new Exception(ex.InnerException != null ? ex.InnerException.Message : ex.Message);
            }
            return res;
        }

        public static bool CopyDbFile(string sourcePath, string targetPath)
        {
            var res = false;
            if (System.IO.File.Exists(sourcePath))
            {
                try
                {
                    System.IO.File.Copy(sourcePath, targetPath);
                    res = true;
                }
                catch (Exception ex)
                {
                    throw new Exception(ex.InnerException != null ? ex.InnerException.Message : ex.Message);
                }
            }
            return res;
        }
    }
}
